﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Asteroids.Game
{
    public class PolarCoordinate
    {
        public PolarCoordinate(double angle, double magnitude)
        {
            Angle = angle;
            Magnitude = magnitude;
        }

        public double Angle { get; set; }
        public double Magnitude { get; set; }

        public static implicit operator Coordinate(PolarCoordinate pc1)
        {
            return new Coordinate(pc1.Magnitude * Math.Cos(pc1.Angle), pc1.Magnitude * Math.Sin(pc1.Angle));
        }

        public static PolarCoordinate operator +(PolarCoordinate pc1, PolarCoordinate pc2)
        {
            return ((Coordinate)pc1) + ((Coordinate)pc2);
        }

        public static PolarCoordinate operator *(PolarCoordinate pc, double n)
        {
            return new PolarCoordinate(pc.Angle, pc.Magnitude * n);
        }

        public override string ToString()
        {
            return String.Format("Angle: {0}pi\t\tMagnitude: {1}", Angle / Math.PI, Magnitude);
        }
    }
}
